from celery import Celery
from celery.schedules import crontab

import os

# celery提交任务
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ccsp_api.settings.dev')
app = Celery('celery')
app.config_from_object('django.conf:settings',
                       namespace='CELERY')

app.autodiscover_tasks()

# 设置定时任务
app.conf.beat_schedule = {
    'delete_older_log': {
        'task': 'backend.tasks.del_old_log',
        # 每天午夜执行清除老的log
        'schedule': crontab(minute='0', hour='0'),
    },
}
